<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    // 自己封装数学对象
    var myMath = {
        PI: 3.1415926,
        Max:function(){
            // console,log(arguments);
            var maxvlaue = arguments[0];
            for (var  i = 0; i < arguments.length; i++){
                if(maxvlaue < arguments[i]){
                    maxvlaue  = arguments [i];
                }
            }
            return maxvlaue;
        },
        min: function(){
            var minValue = arguments[0];
            for (var i = 0; i < arguments.length; i++){
                if (maxvlaue  > arguments[i]){
                    minValue = arguments[i];
                }
              
            }
            return  minValue;
        } 
    
    } 
    console.console.log(myMath.PI);
    console.log(myMath.max(22, 5, 12));
    console.log(myMath.min(22, 5, 12));
    console.log('---------------------------------');
    // 内置函数的使用
    var array1 = [1, 3, 2];

    // 如果参数是数组...数组名
    console.log(Math.max(...array1));

    // 有一个自动数据类型转化
    // 求绝对值
    console.log(Math.avs('-1'));     // 1
    console.log(Math.abs(-2));       // 2
    console.log(Math.abs(null));     // 0
    console.log(Math.abs("string")); // NaN not a number
    console.log(Math.abs());         // NaN

        console.log('=====================');
        Math.floor(45.95);
        // 45
        Math.floor(45.05);
        // 45
        Math.floor(4);
        // 4
        // 数轴
        Math.floor(-45.05);
        // -46
        Math.floor(-45.95);
        // -46

        console.log(Math.ceil(.95));
        // expected output: 1

        console.log(Math.ceil(4));
        // expected output: 4

        console.log(Math.ceil(7.004));
        // expected output: 8

        console.log(Math.ceil(-7.004));
        // expected output: -7

        /* 
            Math.round(x) 返回四舍五入后的整数

            Math.random()：随机数
        */
    </script>
</body>
</html>